import * as React from "react";
import {List, Radio} from "antd-mobile";
const RadioItem = Radio.RadioItem;

export default class QuestionnaireList extends React.Component {

  constructor(props) {
    super(props);
  }

  render() {
    return (
      <div>
        {
          this.props.questions.map((q, num) => (
            <List key={q.id} renderHeader={() => ((num+1) + '、' + q.text)}>
              {q.options.map((a, i) => (
                <RadioItem
                  key={i}
                  disabled={this.props.isVoted}
                  checked={q.result === a.value}
                  onChange={() => this.props.onChange(a.value, q.id)}
                >
                  {a.label}
                </RadioItem>
              ))}
            </List>

          ))
        }
      </div>
    )
  }
}
